package com.fjh.springboot_01.mapper;

import com.fjh.springboot_01.pojo.homework.HomeworkQuestion;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface HomeworkQuestionMapper {
    @Insert("INSERT INTO homework_question (homework_id, question_type, question_content, " +
            "question_options, standard_answer, score, knowledge_point_id, create_time, update_time) " +
            "VALUES (#{homeworkId}, #{questionType}, #{questionContent}, " +
            "#{questionOptions}, #{standardAnswer}, #{score}, #{knowledgePointId}, NOW(), NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(HomeworkQuestion question);

    @Select("SELECT * FROM homework_question WHERE homework_id = #{homeworkId}")
    List<HomeworkQuestion> findByHomeworkId(Integer homeworkId);

    @Select("SELECT * FROM homework_question WHERE id = #{id}")
    HomeworkQuestion findById(Integer id);

    @Update("UPDATE homework_question SET question_content = #{questionContent}, " +
            "question_options = #{questionOptions}, standard_answer = #{standardAnswer}, " +
            "score = #{score}, knowledge_point_id = #{knowledgePointId}, update_time = NOW() " +
            "WHERE id = #{id}")
    void update(HomeworkQuestion question);

    @Delete("DELETE FROM homework_question WHERE id = #{id}")
    void delete(Integer id);
} 